package cn.codergege.demo.config

import com.alibaba.druid.support.http.StatViewServlet
import com.alibaba.druid.support.http.WebStatFilter
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.jdbc.DataSourceBuilder
import org.springframework.boot.web.servlet.FilterRegistrationBean
import org.springframework.boot.web.servlet.ServletRegistrationBean
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Primary
import org.springframework.context.annotation.Profile
import java.util.*
import javax.sql.DataSource

@Profile("dev", "prod")
@Configuration
class DataSourceConfig {

    @Primary
    @ConfigurationProperties(prefix = "spring.datasource.primary")
    @Bean
    fun dataSourcePrimary(): DataSource {
        return DataSourceBuilder.create().build()
    }

    @ConfigurationProperties(prefix = "spring.datasource.secondary")
    @Bean
    fun dataSourceSecondary(): DataSource {
        return DataSourceBuilder.create().build()
    }


}